// 使用ESM格式导入vue-router
import { createRouter as _createRouter, createWebHashHistory } from 'vue-router'

// 路由配置
const routes = [
  // {
  //   name: 'notFound',
  //   path: '/:path(.*)+',
  //   redirect: {
  //     name: 'goods'
  //   }
  // },
  {
    name: 'register',
    path: '/register',
    component: () => import('@/view/register/index.vue'),
    meta: {
      title: '注册'
    }
  }
]

// 创建路由实例
const router = _createRouter({
  routes,
  history: createWebHashHistory()
})

// 全局前置守卫
router.beforeEach((to, from, next) => {
  const title = to?.meta?.title
  if (title) {
    document.title = title as string
  }
  next()
})

// 导出路由实例
export default router